package com.sales.dao;

import com.sales.entity.Profile;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;
import java.util.Set;


/**
 * Created by lihu on 2017/9/7.
 */
public interface ProfileDao extends PagingAndSortingRepository<Profile, String> {

    /**
     * 通过账号获取账号详情
     *
     * @param username
     * @return
     */
    Profile findByUsername(String username);

    /**
     * 获取子账号信息
     *
     * @param username
     * @return
     */
    Page<Profile> findListByParentUserNameOrderByAddTimeDesc(String username, Pageable pageable);


    /**
     * 通过邀请码获取账号信息
     *
     * @param code
     * @return
     */
    Profile findByReferralCode(String code);

    /**
     * 通过邀请码获取账号信息
     *
     * @param codes
     * @return
     */
    List<Profile> findListByReferralCodeIn(Set<String> codes);


    /**
     * 获取子账号信息
     *
     * @param username
     * @return
     */
    List<Profile> findListByParentUserName(String username);

    /**
     * 获取对应邀请码信息
     *
     * @param username
     * @param referralCode
     * @return
     */
    Profile findByParentUserNameAndReferralCode(String username, String referralCode);
}
